package com.ccp.dev.qbdms.util;

import com.ccp.dev.core.basic.util.ContextUtil;
import com.ccp.dev.core.util.BeanUtils;
import com.ccp.dev.system.model.SysOrg;

import java.util.UUID;

/**
 * 项目uuid工具类
 */
public class ProjectUUIDUtils {
    /**
     * 功能描述: 获取32位的UUID随机码(去除"-")，并且增加当前组织code前缀
     * @return java.lang.String
     */
    public static String getUUIDFor32() {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        SysOrg sysOrg = (SysOrg) ContextUtil.getCurrentOrg();
        if(BeanUtils.isNotEmpty(sysOrg)){
            String code = sysOrg.getCode();
            return code + uuid.substring(code.length());
        }
        return uuid;
    }
}
